<?php
// +----------------------------------------------------------------------
// |  [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Released under the MIT License.
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------

namespace app\meeting\controller;

use cmf\controller\AdminBaseController;
use function Sodium\increment;
use think\Db;

class CheckController extends AdminBaseController
{


    /*
     * 租赁服务列表
     * */
    public function index()
    {
        $where=[];
        $where[]=['title','like','%'. input('keyword','') .'%'];
        $data = Db::table('ims_hc_meet')
            ->where($where)
            ->paginate(10);
        $page  =  $data->render();
        $list  = $data->toArray();

        $this->assign('list',$list['data']);
        $this->assign('page',$page);
        return $this->fetch();

    }

    /*
   * lists
   * @param
   * $return
   */
    public function lists()
    {
        if(input('meeting_id')){
            session('MEETING_ID',input('meeting_id'));
        }
        $where[] = ['meeting_id','=', session('MEETING_ID')];
        $where[] = ['number','like', '%'.input('number','').'%'];
        $list  =  Db::table('ims_hc_meet_room_checkaccept')
            ->where($where)
            ->select()->toArray();

        $this->assign('list',$list);
        return $this->fetch();
    }

    /*
     * check
     * @param  
     * $return 
     */
    public function check()
    {
        if($this->request->isPost()){
            $data = input();
            $id     = $data['id'];
            $updatedata = [];
            $updatedata['status'] = $data['status'];
            $updatedata['remark'] = $data['remark'];
            $updatedata['update_time'] = time();
            if( $data['status'] ==2 && empty($data['remark'])){
                $this->error('请填写拒绝理由');
            }
            $result = Db::table('ims_hc_meet_room_checkaccept')->where(['id' => $id])->update($updatedata);
            if ($result) {
                $this->success('成功');exit();
            } else {
                $this->error('失败');
            }
        }

    }

}
